package com.HMS.dao;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

import com.HMS.pojo.User;
@Repository
public class UserDao {
	@Resource
	SessionFactory sessionFactory;

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}
	public boolean insert(User user){
		Session session=sessionFactory.getCurrentSession();
	    session.save(user);
		return true;		
	}
	public Boolean getEmail(User user){
		Boolean bool=true;
		Session session=sessionFactory.getCurrentSession();		
		Query query=session.createQuery("from User where email='"+user.getEmail()+"'");
		List<User> user1=query.list();
		System.out.println(user1.size());
		return bool;	
	}

}
